@extends('admin.layout.ucommon')

@section('content')
    <div class="wrapper wrapper-content animated fadeIn">
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- Example Toolbar -->
                    <div class="example-wrap">
                        <div class="example">
                            <table id="article" data-toggle="table" data-height="500"  data-search="true" data-pagination="true" >
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>房源名称</th>
                                    <th>小区名称</th>
                                    <th>小区地址</th>
                                    <th>租赁方式</th>
                                    <th>业主</th>
                                    <th>租金</th>
                                    <th>朝向</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($data as $list)
                                    <tr>
                                        <td>{{$list->id}}</td>
                                        <td>{{$list->fang_name}}</td>
                                        <td>{{$list->fang_xiaoqu}}</td>
                                        <td>{{$list->fang_addr}}</td>
                                        <td>{{$list->fang_rent_class}}</td>
                                        <td>{{$list->fang_owner}}</td>
                                        <td>{{$list->fang_rent}}</td>
                                        <td>{{$list->fang_direction}}</td>
                                        <td>
                                            <a href="{{route('admin.landlord.edit',$list['id'])}}" class="label label-primary">修改</a>
                                            <a href="{{route('admin.landlord.del',$list['id'])}}" class="label label-danger del">删除</a>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="{{asset('static')}}/layer/layer.js"></script>
    <script>
        $("#article").bootstrapTable({
            search: true,
            showColumns: true,
            striped: true,
            iconSize: 'outline',
            toolbar: '#systemToolbar',
            showExport: true,                //是否显示导出
            exportDataType: 'all',            //导出方式
            exportTypes:[ 'xlsx', 'excel'],  //导出文件类型
            exportOptions: {                 //导出文件名称
                fileName:"文章列表"
            },
            columns:[

            ]
        });


        $('.del').click(function(){
           let _this = $(this);
           //请求的url地址
            let url = _this.attr("href");
            //确认弹框
            layer.confirm('您真的要删除此条记录信息吗?',{
                btn:['确认删除','考虑一下']
            },()=>{
               $.ajax({
                   url,
                   type:'delete',
                   data:{_token:"{{csrf_token()}}"}
               }).then(ret=>{
                   layer.msg(ret.msg,{icon:1,time:2000},()=>{
                      _this.parents('tr').remove();
                   });
               }) ;
            });
        });

        //fetch(url)
    </script>
@endsection




